@extends('layout.admin.index')
@section('content')
<body>
<form method="post" action="" id="listform">
  <div class="panel admin-panel">
  	<!-- 子列表显示 -->
    <div class="panel-head"><strong class="icon-reorder"> {{ $title }}</strong> <a href="" style="float:right; display:none;">添加字段</a></div>
    <div class="padding border-bottom">
      <ul class="search" style="padding-left:10px;">
        <li> <a class="button border-main icon-plus-square-o" href="/admin/admin/add"> 添加管理员</a> </li>
		<form action=""></form>
		
		<!-- 搜索分页表单 -->
        <form action="/admin/admin/index">
	        <li>显示条数
	          <select name="count" class="input"  style="width:60px; line-height:17px; display:inline-block">
	          <!-- 分页进行判断获取设置的条数值 并检测count在未传值时转为空 -->
	            <option value="10" @if(!empty($request['count']) && $request['count'] == 10) selected @endif>10</option>
	            <option value="30" @if(!empty($request['count']) && $request['count'] == 30) selected @endif>30</option>
	            <option value="50" @if(!empty($request['count']) && $request['count'] == 50) selected @endif>50</option>
	          </select>
	          &nbsp;&nbsp;
	        </li>
	        <!-- 分页获取参数并路由跳转致本页面，获取搜索结果 -->
        <li style="float:right">
          <input type="text" placeholder="请输入搜索关键字" name="search" class="input" style="width:250px; line-height:17px;display:inline-block" value="{{ $request['search'] or ''}}"/>
          <input type="submit" class="button border-main icon-search"  value="搜索">
        </li>
        </form>
		<!-- 搜索分页表单 -->

      </ul>
    </div>

    <!-- 管理员列表显示开始 -->
    <form action="/admin/admin/delete" method="get">
    <table class="table table-hover text-center">
      <tr>
        <th width="9%" style="text-align:left; padding-left:20px;">排序</th>
        <th width="6%">用户名</th>
        <th width="10%">邮箱</th>
        <th width="15">创建时间</th>

        <th width="15%">最后登录时间</th>
        <th width="15%">管理员级别</th>
        <th width="15%">是否禁用</th>
        <th width="15%">操作</th>
      </tr>
      <volist name="list" id="vo">
    	@foreach($data as $k => $v)
        <tr>
        <!-- 获取管理员id -->
          <td style="text-align:left; padding-left:20px;">
          	  <input type="checkbox" name="id[]" value="{{ $v['id'] }}" />{{ $k+1 }}
          </td>
          <!-- 获取管理员用户名 -->
          <td>{{ $v['admin_name'] }}</td>

          <!-- 获取管理员邮箱 -->
          <td>{{ $v['admin_email'] }}</td>

          <!-- 获取创建时间 -->
          <td>{{ $v['admin_createtime'] }}</td>

          <!-- 获取登录时间 -->
          <td>{{ $v['admin_time'] }}</td>

          <!-- 获取登录ip -->
          <td>{{ $v['role_name'] }}</td>

          <!-- 判断是否被禁用 -->
          <td>
          		@if($v['admin_shield'] == 1) <font color="green">已开启</font> 
          		@else  <font  color="red">已禁用</font>
          		@endif
          </td>
          <td>
          	<div class="button-group">
          		<a class="button border-main" href="/admin/admin/edit/{{ $v['id'] }}"><span class="icon-edit"></span> 编辑</a>
          		<a href="/admin/admin/delete?id[]={{ $v['id'] }}" class="button border-red" onclick="return del()">删除</a>
          	</div>
          </td>
        </tr>
        @endforeach
		<!-- 管理员列表显示结束 -->

      <tr>
        <td style="text-align:left; padding:19px 0;padding-left:20px;"><input type="checkbox" id="checkall" />
          全选 </td>
        <td colspan="7" style="text-align:left;padding-left:20px;">
        	<input type="submit" value="删除" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="return DelSelect()">
        </td>
      </tr>
	  </form>
      <tr>
        <td colspan="8">
        	<div class="pagelist">
        		<!-- 分页显示 -->
        		{!! $data -> appends($request) ->render() !!}
        	</div>
        </td>
      </tr>

    </table>

  </div>
</form>
<script type="text/javascript">
function del()
{
	if(confirm('确定要删除该管理员吗') == false){
		return false;
	}

}
//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
	  }
	  else {
		  this.checked = true;
	  }
  });
})

//批量删除
function DelSelect(){
	var Checkbox=false;
	 $("input[name='id[]']").each(function(){
	  if (this.checked==true) {		
		Checkbox=true;	
	  }
	});
	if (Checkbox){
		var t=confirm("您确认要删除选中的内容吗？");
		if (t==false) return false;		
		$("#listform").submit();		
	}
	else{
		alert("请选择您要删除的内容!");
		return false;
	}
}
</script>
</body>
@endsection